package cn.edu.ctbu.sbadmin.grade.dao;


import cn.edu.ctbu.sbadmin.common.core.MyMapper;
import cn.edu.ctbu.sbadmin.grade.domain.DimClassDO;
import cn.edu.ctbu.sbadmin.grade.domain.StudentDO;
import cn.edu.ctbu.sbadmin.grade.domain.SubjectDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*
 * @description 
 * @param null
 * @author HighJ
 * @date 2022/4/13 9:51
 */

@Mapper
public interface StudentDao extends MyMapper<StudentDO> {

    @Select("SELECT\n" +
            "student.id,\n" +
            "student.s_no as username,\n" +
            "student.`name`,\n" +
            "student.class_id,\n" +
            "student.gender,\n" +
            "student.`password`,\n" +
            "student.last_time,\n" +
            "student.last_ip,\n" +
            "student.avatar,\n" +
            "student.gmt_create,\n" +
            "student.gmt_modified,\n" +
            "student.is_deleted,\n" +
            "student.gmt_delete,\n" +
            "student.delete_userid,\n" +
            "dim_class.class_name\n" +
            "FROM\n" +
            "student\n" +
            "LEFT JOIN dim_class ON student.class_id = dim_class.id \n"+
            "${ew.customSqlSegment}")
    IPage<StudentDO> selectPage(IPage<StudentDO> page,
                                 @Param(Constants.WRAPPER)QueryWrapper<StudentDO> queryWrapper);

    @Select("SELECT\n" +
            "student.id,\n" +
            "student.s_no as username,\n" +
            "student.`name`,\n" +
            "student.class_id,\n" +
            "student.gender,\n" +
            "student.`password`,\n" +
            "student.last_time,\n" +
            "student.last_ip,\n" +
            "student.avatar,\n" +
            "student.gmt_create,\n" +
            "student.gmt_modified,\n" +
            "student.is_deleted,\n" +
            "student.gmt_delete,\n" +
            "student.delete_userid,\n" +
            "dim_class.class_name\n" +
            "FROM\n" +
            "student\n" +
            "LEFT JOIN dim_class ON student.class_id = dim_class.id \n"+
            "${ew.customSqlSegment}")
    List<StudentDO> get(@Param(Constants.WRAPPER) QueryWrapper<SubjectDO> queryWrapper);

}
